package com.my.hp_hr.contorller;


import com.my.hp_hr.entity.Attendance;
import com.my.hp_hr.service.AttendanceService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/attendanceListServlet")
public class AttendanceListServlet extends HttpServlet {
    private AttendanceService attendanceService = new AttendanceService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            List<Attendance> list = attendanceService.getAttendanceList();
            for (Attendance attendance : list) {
                System.out.println(attendance);
            }
            req.setAttribute("list",list);
            req.getRequestDispatcher("attendance_list.jsp").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
